#pragma once

#include "CoreMinimal.h"
#include "SkeletalInstancedSubsystem.generated.h"

class USkelotAnimCollection;
class FSkeletalInstancedProxyAbstract;
class USkelotComponent;
class ASlgSkeletalInstanceActor;

UCLASS(BlueprintType, config = Game)
class SKELOT_API USkeletalInstancedSubsystem : public UWorldSubsystem
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintPure)
	static USkeletalInstancedSubsystem* Get(const UObject* WorldContext);

public:
	void Register(FSkeletalInstancedProxyAbstract* Proxy);
	void UnRegister(FSkeletalInstancedProxyAbstract* Proxy);
public:
	UFUNCTION(BlueprintCallable)
	ASlgSkeletalInstanceActor* GetInstancedBatchActor();
	USkelotComponent* FindComponent(FSkeletalInstancedProxyAbstract* Proxy);
	UFUNCTION(BlueprintCallable)
	USkelotAnimCollection* FindAnimCollection(USkeleton* Skeleton);
protected:
	void InitializeAnimCollection();
	USkelotAnimCollection* CreateAnimCollection(USkeleton* Skeleton);
protected:
	TSet<FSkeletalInstancedProxyAbstract*> ProxySet;

	UPROPERTY()
	ASlgSkeletalInstanceActor* InstancedBatchActor;

	UPROPERTY()
	TMap<USkeleton*, USkelotAnimCollection*> AnimCollectionMap;
protected:
	UPROPERTY(Config, meta = (MetaClass = "/Script/Skelot.SkelotAnimCollection"))
	TArray<FSoftObjectPath> AnimCollectionSoftObjectPaths;

	UPROPERTY(Config, meta = (MetaClass = "/Script/Skelot.SkelotComponent"))
	FSoftClassPath SkelotComponentSoftClassPath;
};